#include "SslMain.h"
using namespace spt;

static IntCallBack Int1MsCallBack = 0;
static bool8 Int1MsEnable = 0;
static IntCallBack IntSampCallBack = 0;
static bool8 IntSampEnable = 0;

static volatile int64 powerUpTimeMs = 0;
static volatile int64 powerUpTimeSamp = 0;

void spt::EnableSpt1MsInt(IntCallBack CallBack, bool8 Enable)
{
	if (CallBack)
	{
		Int1MsCallBack = CallBack;
	}

	Int1MsEnable = Enable;
}
void spt::EnableSptSampInt(IntCallBack CallBack, bool8 Enable)
{
	if (CallBack)
	{
		IntSampCallBack = CallBack;
	}

	IntSampEnable = Enable;

}

extern "C" void Ssl1MsInt()
{
	powerUpTimeMs++;
	if (Int1MsEnable && Int1MsCallBack)
	{
		Int1MsCallBack();
	}



}

extern "C" void SslSampInt()
{
	powerUpTimeSamp++;
	if (IntSampEnable && IntSampCallBack)
	{
		IntSampCallBack();
	}
}

int64 spt::PowerUpTimeMs()
{
	volatile int64 msNow = powerUpTimeMs;

	while (msNow != powerUpTimeMs)
	{
		msNow = powerUpTimeMs;
	}

	return int64(msNow);
}

int64 spt::PowerUpSampNum()
{
	volatile int64 snum = powerUpTimeSamp;

	while (snum != powerUpTimeSamp)
	{
		snum = powerUpTimeSamp;
	}

	return int64(snum);
}

